export default function (TaskData = []) {
	const resultNumbers = [];
	TaskData.forEach(task => {
		const warnings = task.result.warnings || [];
		const result = task.result;
		const resultNumber = warnings.reduce(
			(obj, item) => {
				if (item.level === 1) {
					obj.lowWarnCount++;
				} else if (item.level === 2) {
					obj.mediumWarnCount++;
				} else {
					obj.highWarnCount++;
				}
				return obj;
			},
			{
				highWarnCount: 0,
				mediumWarnCount: 0,
				lowWarnCount: 0,
			}
		);
		const resultNumber2 = result.addition?.detail?.reduce(
			(res, item) => {
				if (item.securityStatus === 'warning') {
					res.abnorNodeCount++;
				} else {
					res.normalNodeCount++;
				}
				res.totalNodeCount++;
				return res;
			},
			{
				abnorNodeCount: 0,
				normalNodeCount: 0,
				totalNodeCount: 0,
			}
		);
		resultNumbers.push({
			taskType: task.taskType,
			uid: task.uid,
			jobId: task.jobId,
			taskName: task.name,
			target: task.target,
			datetime: task.endTime,
			taskId: task._id,
			warnCount: task.result.warningCount,
			aviliable: result.addition?.detail,
			...resultNumber2,
			...resultNumber,
		});
	});
	return resultNumbers;
}
